import DTO.User;
import java.io.*;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "ServletZ",urlPatterns ="/ServletZ")
public class ServletZ extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       String username=request.getParameter("username");
       String password=request.getParameter("password");
       String email=request.getParameter("email");
       String phone=request.getParameter("phone");
       String str=username+" "+password+" "+email+" "+phone;
       FileWriter tofile=new FileWriter("infor.txt",true);
       BufferedWriter out=new BufferedWriter(tofile);
       out.write(str);
       out.newLine();
       out.close();
       tofile.close();
       response.sendRedirect("http://localhost:8080/login.jsp");
    }
}
